// ==================================================================================================
// Copyright(C) 2018 FI Ltd. All rights reserved.
//
// SYSTEM NAME	: FI.Net Application Framework
// COMPONENT ID	: FI.Architecture.Server
// COMPONENT DESC:		
//
// CREATED DATE/BY:		18 Aug 2018 / Tian Mi
//
// REVISION HISTORY:	DATE/BY			SR#/CS/PM#/OTHERS		DESCRIPTION OF CHANGE
// ==================================================================================================

using FI.Core;
using FI.Core.IoC;
using FI.Helpers.Data;

namespace FI.Architecture.Server
{
    /// <summary>
    /// Base class of data access, it providers application context and db helper.
    /// </summary>
    public class DataAccessBase : ApplicationContextAwareObject, IServiceLocatableObject
    {
        #region Private Fields
        private DbHelper dbHelper;
        #endregion

        #region Properties
        /// <summary>
        /// Gets the service locator.
        /// </summary>
        /// <value>The service locator.</value>
        public IServiceLocator ServiceLocator
        {
            get { return ServiceLocatorFactory.GetServiceLocator(); }
        }

        /// <summary>
        /// Gets the <see cref="DbHelper"/> which is used for Database base access.
        /// </summary>
        /// <value>The helper.</value>
        protected virtual DbHelper Helper
        {
            get
            {
                return dbHelper ?? (dbHelper = new DbHelper());
            }
        }
        #endregion
    }
}